<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display" %>
<%@ page import="com.cs.beneficios.business.model.AtributoVO"%>

<script language="JavaScript" src="<%= request.getContextPath() + "/js/calendar6.js" %>"></script>
<script language="JavaScript" src="<%= request.getContextPath() + "/js/popUP.js" %>"></script>

<%@ page contentType="text/html;charset=utf-8"%>

<html>
  <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>M&oacute;dulo de Secretarias</title>
    <link href="../../css/jdeveloper.css" rel="stylesheet" media="screen"/>
    <script language="JavaScript"> 

       function habilita(){
          if(document.frmsecretarias.subarea.value == "S")
          {
            document.frmsecretarias.code.disabled = false; 
          }else
          {
            document.frmsecretarias.code.disabled = true;
          }
       }
       
       function validardatos(){
        if(document.frmsecretarias.nombrearea.value != "")
        {
          if(document.frmsecretarias.subarea.value == "S")
          {
            if(document.frmsecretarias.code.value != "")
            {
              document.frmsecretarias.opcion.value='2';
              document.frmsecretarias.submit();
            }else
            {
              alert("Por favor seleccione la secretaria a la que pertenece");
            }
          }else
          {
            document.frmsecretarias.opcion.value='2';
            document.frmsecretarias.submit();
          }
        }else
        {
          alert("Por favor ingrese el nombre de la secretaria");
        }
      }
      
      function enviar(locacion1)
      {
        document.frmsecretarias.opcion.value='1';
        document.frmsecretarias.action=locacion1;
        document.frmsecretarias.submit();
      }
              
    </script>
  
  </head>
  <body>
  
   <link href="<%= request.getContextPath() + "/css/bloques.css" %>" rel="stylesheet" type="text/css"> 
    <P align="center" class="titulosenblanco">M&oacute;dulo de Secretarias</P>
    <form name="frmsecretarias" action="<%= request.getContextPath() + "/Areas/ModuloAreas.do" %>" method="get">
      <table border="0" width="50%" height="34" align="center" cellspacing="1" cellpadding="2">
        
        <tr>
          <td>
            <DIV align="left" class="celdatabla">
              <STRONG>Nombre</STRONG>
            </DIV>
          </td>
          <td>
            <input type="text" name="nombrearea" size="40" maxlength="99" class="form"/>
          </td>
        </tr>
         <tr align="left">
          <td>
            <DIV align="left" class="celdatabla">
              <strong>Descripci&oacute;n</strong>
            </DIV>
          </td>
          <td>
            <DIV align="left">
              <input type="text" name="descripcionarea" size="40" maxlength="199" class="form"/>
            </DIV>
          </td>
        </tr>
        <tr>
          <td align="left" class="celdatabla"><strong>Subsecretaria?</strong></td>
          <td align="left">
            <SELECT onchange="habilita()" NAME="subarea" Class="form">
                  <OPTION value="N">NO</OPTION>
                  <OPTION value="S">SI</OPTION>
             </SELECT>
          </td>
        </tr>
        <tr>
          <td align="left" class="celdatabla"><strong>Escoja la Secretaria padre</strong></td>
          <td align="left">
            <logic:iterate id="areas" name="ListaAllAreas" length="1" type="com.cs.beneficios.business.model.AreaVO">
              <html:select name="areas"  property="code" styleClass="form">
                <html:options name="ListaAllAreas" labelName="AreaPadre" labelProperty="nombre" property="code" collection="ListaAllAreas"/>
              </html:select>
            </logic:iterate>
          </td>   
        </tr>
    </table>
    <br/>
    <div align="center">
      <%String Ruta = "'"+request.getContextPath() + "/Areas/ModuloAreas.do'";%>
      <input type="HIDDEN" name="opcion"/>
      <input type="BUTTON" value="Consultar" onclick="enviar(<%=Ruta%>)"/>
      <input type="BUTTON" value="Ingresar" onclick="validardatos()"/>
    </div>
    <br/>
    <table  cellspacing="3" cellpadding="2" border="0" align="center">
        
        <tr>
        <td>
          <div align="center">
          <logic:present scope="request" name="ListaAreas">
            <display:table name="requestScope.ListaAreas" id="listArea" pagesize="20" requestURI='<%= request.getContextPath() + "/Areas/ModuloAreas.do" %>' style="width:100%" class="bordesTable">
              <display:column headerClass="headerTable" property="nombre" title="NOMBRE" class="Numero" sortable="true">
              </display:column>
              <display:column headerClass="headerTable" property="descripcion" title="DESCRIPCION" class="Numero" sortable="true"> 
              </display:column>
              <display:column headerClass="headerTable" title="SUBSECRETARIAS" class="Numero" >
                  <DIV align="center">
                  <html:link paramId="code" paramName="listArea" paramProperty="code" page="/Areas/SubAreas.do">
                      <img border="0" src="<%=request.getContextPath() + "/images/ver.gif"%>"/>
                  </html:link>
                  </DIV>
             </display:column>
             <display:column headerClass="headerTable" title="MODIFICAR" class="Numero" >
                  <DIV align="center">
                  <html:link paramId="code" paramName="listArea" paramProperty="code" page="/Areas/ModificationAreas.do">
                      <img border="0" src="<%=request.getContextPath() + "/images/modificar.gif"%>"/>
                  </html:link>
                  </DIV>
             </display:column>   
           </display:table>
          </logic:present>
          
          <logic:notPresent scope="request" name="ListaAreas">
            <strong><DIV align="center">La secretaria no existe</DIV></strong>
            <BR/>
          </logic:notPresent>
           
          </div>
        </td>
        </tr>
      </table>
    
    </form>
  </body>
</html>
